﻿using Core.AbstractEntities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Stack.Entities;
using Types;

namespace Test
{
    /// <summary>
    /// Testing Parser
    /// </summary>
    [TestClass]
    public class UnitTest_Parser
    {
        /// <summary>
        /// The pile "parse" the type "HpTypeRpl", the type HpTypeRPL 
        /// </summary>
        [TestMethod]
        public void TestParser_DUP()
        {
            HpPile hpPile = new HpPile();
            Rpl testRPL = new Rpl();
            testRPL.Value = "« DUP »";

            hpPile.AddElement(new HpElement()
            {
                Value = 3.141516
            });

            hpPile.AddElement(new HpElement()
            {
                Value = "« DUP »",
                Type = testRPL.GetType()
            });

            Assert.AreEqual(3.141516, hpPile.Get(0).Value);
            Assert.AreEqual(3.141516, hpPile.Get(1).Value);
        }
        /// <summary>
        ///Initialitation of the elements in the pile
        /// </summary>
        /// <param name="hpile">Collection</param>
        private static void InitialiseForTesthpile(HpPile hpile)
        {
            HpElement element1 = new HpElement();
            element1.Value = 1;

            HpElement element2 = new HpElement();
            element2.Value = "this is a string";

            HpElement element3 = new HpElement();
            element3.Value = 'c';

            HpElement element4 = new HpElement();
            element4.Value = 3.141516;

            //Add element integer
            hpile.AddElement(element1);
            //Add element string
            hpile.AddElement(element2);
            ////Add element character
            hpile.AddElement(element3);
            ////Add element double
            hpile.AddElement(element4);
        }
    }
}
